package com.sample.action;
/**
 * 经办点action
 */
import java.util.List;
import com.sample.action.form.InstitutionForm;
import com.sample.javabean.Area;
import com.sample.javabean.Institution;
import com.sample.util.Pager;

public class InstitutionAction extends BaseAction{

	private static final long serialVersionUID = -8246880976028864353L;
	private Institution ins = new Institution();
	private InstitutionForm insForm = new InstitutionForm();
	private String in_ins_no;
	private Pager<Institution> pageList;
	private List<Area> areaList;
	
	public InstitutionAction() {
		super();
	}
	/**
	 * 添加经办点
	 * @return
	 */
	public String inputIns(){
		Area area = new Area();
		try {
			areaList = area.findAll();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "inputIns";
	}
	public String addIns()throws Exception{
		try{
			if(insForm!=null){
				ins.addIns(insForm);
			}
			return SUCCESS;
		}catch (Exception e) {
			
			e.printStackTrace();
			throw new Exception("添加经办点失败！Exception_action:<--"+e+"-->"); 
		}
	}
	
	/**
	 * 删除经办点
	 * @return
	 * @throws Exception
	 */
	public String delIns()throws Exception{
		try{
			if(insForm!=null){
				ins.setIn_ins_no(in_ins_no);
				ins.delIns();
			}
			return SUCCESS;
		}catch (Exception e) {
			e.printStackTrace();
			throw new Exception("删除经办点失败！Exception_action:<--"+e+"-->"); 
		}	
		
	}
	
	/**
	 * 编辑经办点信息
	 * @return
	 * @throws Exception
	 */
	public String editIns()throws Exception{
		try{
			ins.setIn_ins_no(in_ins_no);
			ins.load();
			Area area = new Area();
				areaList = area.findAll();
		
			return "editIns";
		}catch (Exception e) {
			e.printStackTrace();
			throw new Exception("加载经办点信息失败！Exception_action:<--"+e+"-->"); 
		}	
	}
	
	public String edit()throws Exception{
		try{
			if(insForm!=null){
				LOG.info("bul?"+ins.getIn_ins_no());
			ins.editIns(insForm);
			}
			return SUCCESS;
		}catch (Exception e) {
			e.printStackTrace();
			throw new Exception("编辑经办点信息失败！Exception_action:<--"+e+"-->"); 
		}	
	}
	
	/**
	 * 分页显示
	 * @return
	 * @throws Exception
	 */
	public String listIns()throws Exception{
		try{
			pageList=ins.list(page, size,insForm);
			return "listIns";
		}catch (Exception e) {
			e.printStackTrace();
			throw new Exception("分页显示失败，Exception_Action:"+e);
		}
	}
	
	
	public Institution getIns() {
		return ins;
	}
	public void setIns(Institution ins) {
		this.ins = ins;
	}
	public InstitutionForm getInsForm() {
		return insForm;
	}
	public void setInsForm(InstitutionForm insForm) {
		this.insForm = insForm;
	}
	public String getIn_ins_no() {
		return in_ins_no;
	}
	public void setIn_ins_no(String in_ins_no) {
		this.in_ins_no = in_ins_no;
	}
	public Pager<Institution> getPageList() {
		return pageList;
	}
	public void setPageList(Pager<Institution> pageList) {
		this.pageList = pageList;
	}
	public List<Area> getAreaList() {
		return areaList;
	}
	public void setAreaList(List<Area> areaList) {
		this.areaList = areaList;
	}
	

}
